package test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.hardy.freemakerhelper.FreeMakerPaging;
import org.hardy.freemakerhelper.FreemakerUtil;
import org.hardy.serialization.javaSerialize.JavaSerialization;
import org.hardy.statics.constants.PathMode;
import org.hardy.util.io.conversion.ObjectConversion;

import com.google.gson.Gson;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.Version;

public class FreeWrod {

	public static void main(String[] args) throws TemplateException, IOException {
		JavaSerialization<Map<String,String>> jr = new JavaSerialization<>();
		File f = new File("C:\\workspace\\test\\education\\json\\aaa.txt");
		ObjectConversion oc = new ObjectConversion();
		Map<String,Object> map = oc.streamToObject(new FileInputStream(f));
		String[] arrs = new String[] {"cy","cm","cd","py","pm","pd","ty","tm","td"};
		Arrays.stream(arrs).forEach(key->{
			map.put(key, "2012");
		});
		System.out.println(new Gson().toJson(map));
//		HttpServletRequest request = null;
//		FreeMakerPaging fr = new FreeMakerPaging(freemarker.template.Configuration.VERSION_2_3_23,"UTF-8",request,
//				PathMode.FILE,"C:/templateAA/docTemplateX",new FreemakerUtil.Configur() {
//
//					@Override
//					public void supplement(freemarker.template.Configuration configuration) {
//						configuration.setDefaultEncoding("UTF-8");
//						configuration.setOutputEncoding("UTF-8");
//					}
//		});
//		Template template = fr.getTemplate("TrainingCard.flt", request);
//		JavaSerialization<Map<String,String>> jr = new JavaSerialization<>();
//		File f = new File("C:\\workspace\\test\\education\\json\\aaa.txt");
//		ObjectConversion oc = new ObjectConversion();
//		Map<String,Object> map = oc.streamToObject(new FileInputStream(f));
//		String[] arrs = new String[] {"cy","cm","cd","py","pm","pd","ty","tm","td"};
//		Arrays.stream(arrs).forEach(key->{
//			map.put(key, "2012");
//		});
//		System.out.println(map);
//		FreemakerUtil.writeToDiskFile(template, map, new File("C:/templateAA/docTemplateX/qq.doc"));
	}
	
}
